<!DOCTYPE html>
<html lang="en">
<title>储值卡用户充值记录</title>
<#import "/layout/layout.html" as body/>
<@body.page>
<style>
    .ibox-footer h4 span {
        margin-right: 25px
    }
</style>

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5 class="pull-left">用户充值记录</h5>
                </div>
                <div class="ibox-content">
                    <div class="table-responsive">
                        <form class="form-inline"  action="to_recharge_list" role="form" id="form" method="post" accept-charset="UTF-8">
                            <div class="form-group">
                                <label for="storeName">充值时间：</label>
                                <div class="input-group date">
                                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                    <input type="text" class="form-control" id="createTime" name="createTime" value="${createTime!}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label>充值方式：</label>
                                <select class="form-control" id="rechargeType" name="rechargeType">
                                    <option value="0" <#if rechargeType=0 > selected="selected"</#if> >全部</option>
                                    <option value="1" <#if rechargeType=1 > selected="selected"</#if> >在线支付</option>
                                    <option value="2" <#if rechargeType=2 > selected="selected"</#if>>兑换码</option>
                                </select>
                            </div>
                            <input type="hidden" id="pageNo" value="${pageNo!}" name="pageNo">
                            <input type="hidden" id="userId" name="userId" value="${userId!}">
                            <button type="submit" class="btn btn-outline btn-primary" style="margin-top: 5px" >确认</button>
                        </form>
                        <hr style="width: 100%">
                        <table class="table table-hover table-center dataTables-example">
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th>充值方式</th>
                                <th>充值金额</th>
                                <th>实到金额</th>
                                <th>兑换码</th>
                                <th>订单号</th>
                                <th>充值时间</th>
                            </tr>
                            </thead>
                            <tbody>
                            <#if list??> 
                            	<#list list as list>
										<tr>
											<td>${list_index + 1}</td>
											<td>
												<#if list.rechargeType == 1>
													微信充值
												</#if>
												<#if list.rechargeType == 2>
													兑换码充值
												</#if>
												
											</td>
											<td>${list.faceAmt!}</td>
											<td>${list.actualAmt!}</td>
											<td>
												<#if list.rechargeType == 2>
													${list.changeCode!}
												</#if>
											</td>
											<td>
												<#if list.rechargeType == 1>
													${list.changeCode!}
												</#if>
											</td>
											<td>${list.createTime?datetime}</td>
										</tr>
									</#list> 
								</#if>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="ibox-footer overflow">
                    <h4 class="pull-left">
                        用户ID：<span>${NO!}</span>
                        用户昵称：<span>${userName!}</span>
                        当前余额：<span>¥${userAccount!}</span>
                        合计充值：<span>¥${userAmount!'0'}</span>
                    </h4>
                    <div id="copot-page" class="pull-right"></div>
                </div>
                <div class="">
                	<a href="${baseUrl}system/custom/to_custom_list"><button class="btn btn-outline btn-primary">返回列表页</button></a>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="${baseUrl}js/main.js"></script>
<script>
    $(document).ready(function () {
        $('.input-group.date').datepicker({
            todayBtn: "linked",
            keyboardNavigation: false,
            forceParse: false,
            //calendarWeeks: true,
            autoclose: true,
            format: 'yyyy-mm-dd',
        });
        //导出excel
        ExampleFile("用户excel");
        $("#createTime").click(function(){
        	$("#pageNo").val(1);
        });
        //分页
        new Page({
            parent: $("#copot-page"),
            nowPage: ${pageNo!},
            pageSize: 10,
            totalCount: ${pageAccount!},
            setting: {
                defaultPage: 7,//默认显示可点击分页的个数
                firstPageText: "首页",
                prevPageText: "上一页",
                nextPageText: "下一页",
                lastPageText: "尾页"
            },
            callback: function (nowPage, totalPage) {
               /*  alert("当前" + nowPage + "页--总共有" + totalPage + "页") */
            	$("#pageNo").val(nowPage);
           	 	$("#form").submit();
            }
        });
        
        
    });
    function amt_refund(order_number,refund_id,id,face_amt){
    	var refund_amt = $("#"+refund_id).val();
    	if(refund_amt > face_amt){
    		swal("退款失败!", "输入的退款金额不能大于实际的充值金额", "error");
    	}
    	swal({
            title: "确定退款金额为："+refund_amt,
            text: "退款之后金额直接打入对方账户!",
            type: "warning",
            showCancelButton: true,
            cancelButtonText: "容我三思！",
            confirmButtonText: "确定!",
        }).then(function () {
            $.ajax({
                url: "card_refund",              // 请求地址
                data: {
                    "order_number": order_number,
                    "biaoshi": 1,
                    "amt":refund_amt,
                    "consume_id":id
                },
                type: 'post',
                cache: false,
                dataType: 'json',
                success: function (data) {
                    swal("退款成功!", "您已退款成功,金额将打入对方账户", "success");
                },
                error: function () {
                    swal("退款失败!", "请联系管理员处理", "error");
                }
            });

        }, function () {
    	});
    }
</script>
</@body.page>
</html>